package com.funo.main.dao.impl;

import java.util.List;

import org.springframework.stereotype.Repository;

import com.funo.core.base.BaseDao;
import com.funo.main.dao.RoleModuleDao;
import com.funo.main.entities.RoleModule;

/**
 * 角色与模块关系接口实现类
 * 
 * @author zhengjs
 *
 */
@Repository
public class RoleModuleDaoImpl extends BaseDao<RoleModule, String> implements RoleModuleDao {

	@Override
	public List<RoleModule> getByRole(String id) {
		List<RoleModule> list = super.findByHql(
				"from RoleModule where role.id = ?", id);
		return list.size() > 0 ? list : null;
	}

	@Override
	public void deleteByHql(RoleModule roleModule) {
		super.executeHql(
				"delete from RoleModule where role.id = ? and module.id = ?",
				new Object[] { roleModule.getRole().getId(),
						roleModule.getModule().getId() });
	}

}
